﻿<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPages/TwoColumn.Master" AutoEventWireup="true"
    CodeBehind="ProductView.aspx.cs" Inherits="TelerikStore.ProductView" %>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <telerik:RadAjaxManagerProxy ID="RadAjaxManagerProxy1" runat="server">
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="ProductPreviousButton">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="ProductPanel" />
                    <telerik:AjaxUpdatedControl ControlID="ProductPreviousButton" UpdatePanelRenderMode="Inline" />
                    <telerik:AjaxUpdatedControl ControlID="ProductNextButton" UpdatePanelRenderMode="Inline" />
                </UpdatedControls>
            </telerik:AjaxSetting>
            <telerik:AjaxSetting AjaxControlID="ProductNextButton">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="ProductPanel" />
                    <telerik:AjaxUpdatedControl ControlID="ProductPreviousButton" UpdatePanelRenderMode="Inline" />
                    <telerik:AjaxUpdatedControl ControlID="ProductNextButton" UpdatePanelRenderMode="Inline" />
                </UpdatedControls>
            </telerik:AjaxSetting>
        </AjaxSettings>
    </telerik:RadAjaxManagerProxy>
    <div id="product-category">
        <h2>
            <asp:Label ID="InformationLabel" runat="server"></asp:Label>
        </h2>
        <div id="search-form">
            <telerik:RadTextBox ID="SearchBox" runat="server" EmptyMessage="Search an item..."
                AutoPostBack="true" OnTextChanged="PerformSearch">
                <ClientEvents OnKeyPress="searchBoxKeyPress" />
            </telerik:RadTextBox>
            <telerik:RadButton ID="SearchButton" runat="server" Text="Search" AutoPostBack="true"
                OnClick="PerformSearch" OnClientClicking="searchButtonClicking" />
            <br />
            <span id="SearchError"></span>
        </div>
    </div>
    <div class="paging simple-paging">
        <telerik:RadButton ID="ProductPreviousButton" runat="server"
            OnClick="ProductPreviousButton_Click" Visible="true" CssClass="prev" OnClientMouseOver="previousButtonMouseOver"
            OnClientMouseOut="previousButtonMouseOut" OnClientClicking="navButtonClickHandler" />
        <telerik:RadButton ID="ProductNextButton" runat="server" OnClientMouseOver="nextButtonMouseOver"
            OnClientMouseOut="nextButtonMouseOut" OnClick="ProductNextButton_Click" Visible="true"
            CssClass="next" OnClientClicking="navButtonClickHandler" />
        <asp:Label ID="NextOrPrevous" runat="server" CssClass="displayTitle">
        </asp:Label>
    </div>
    <asp:Panel ID="ProductPanel" runat="server">
        <div class="product">
            <span class="thumb">
                <asp:Image ID="ProductImage" runat="server" Width="100%" Height="100%" />
            </span>
            <h2 class="title">
                <asp:Label ID="ProductTitleLabel" runat="server" />
            </h2>
            <div class="desc">
                <asp:Label ID="ProductDescriptionLabel" runat="server" />
            </div>
            <p class="price-and-buy">
                <span class="price">
                    <asp:Label ID="ProductPriceLabel" runat="server" />
                </span><span class="buy">
                    <telerik:RadButton ID="BuyButton" runat="server" Text="Buy now" AutoPostBack="true"
                        OnClick="BuyButton_Click" />
                </span>
            </p>
            <div class="saving-rate">
                <asp:Label ID="Savings" runat="server" /></div>
        </div>
        <asp:HiddenField ID="CurrentIndex" runat="server" />
    </asp:Panel>
    <telerik:RadCodeBlock ID="RadCodeBlock" runat="server">
        <script type="text/javascript">

            function searchBoxKeyPress(sender, args) {

                var code = args.get_keyCode();
                if (code == 13 && sender.get_textBoxValue() == "") {
                    args.set_cancel(true);
                }
            }

            function nextButtonMouseOver(sender, args) {

                var index = $get("<%= CurrentIndex.ClientID %>").value;
                PageMethods.GetNextOrPrevious(true, index, onSuccess)
            }

            function previousButtonMouseOver(sender, args) {
                var index = $get("<%= CurrentIndex.ClientID %>").value;
                PageMethods.GetNextOrPrevious(false, index, onSuccess)
            }

            function nextButtonMouseOut(sender, args) {
                $telerik.$(".displayTitle").text("");
            }

            function previousButtonMouseOut(sender, args) {
                $telerik.$(".displayTitle").text("");
            }

            function onSuccess(CategoryTitle) {
                $telerik.$(".displayTitle").text(CategoryTitle);
            }

            function searchButtonClicking(sender, args) {
                var textBox = $find("<%=SearchBox.ClientID %>")
                if (textBox.get_value() == "") {
                    args.set_cancel(true);
                }
            }

            function navButtonClickHandler(sender, args) {
                isAjax = true;
            }

            function onRespondEnd(sender, args) {
                isAjax = false;
            }
        </script>
    </telerik:RadCodeBlock>
</asp:Content>
<asp:Content ID="LeftContent" ContentPlaceHolderID="LeftSideContent" runat="server">
</asp:Content>
